﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Office.Core;
using PowerPoint = Microsoft.Office.Interop.PowerPoint;
//using Graph = Microsoft.Office.Interop.Graph;
using System.Runtime.InteropServices;

namespace WiTeach.ClassManagement.Other
{
    class OpenPresentation
    {
        #region  变量定义
        bool bAssistantOn;
        PowerPoint.Application objApp = null;
        PowerPoint.Presentations objPresSet = null;
        PowerPoint._Presentation objPres = null;
        PowerPoint.SlideShowSettings objSSS = null;
        #endregion

         public void Open(string filePath)
        {
            try
            {
                //Create a new presentation based on a template.
                objApp = new PowerPoint.Application();
                objApp.Visible = MsoTriState.msoTrue;
                objPresSet = objApp.Presentations;
                // 设置窗体大小
                objApp.WindowState = PowerPoint.PpWindowState.ppWindowMaximized;
            
            
                objPres = objPresSet.Open(filePath,
                    MsoTriState.msoFalse, MsoTriState.msoTrue, MsoTriState.msoTrue);
                objApp.Assistant.On = false;

                ////Run the Slide show from slides 1 thru 3.
                objSSS = objPres.SlideShowSettings;
                objSSS.Run();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                //objApp.Quit();
            }

            //Close the presentation without saving changes and quit PowerPoint.
            //objPres.Close();
            //objApp.Quit();
        }

    }


}
